home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / patches / patch2amitcp_4.3 / patch / amitcp / ssrx / dial.ssrx < prev    next >
Encoding:
Text File  |  1996-03-30  |  1.9 KB  |  98 lines

  1. /*
  2.  *    $Id$
  3.  *
  4.  *    AmiTCP/IP Dial Script Subroutine to Dial a number.
  5.  *      Modem must be in command state before this.
  6.  *
  7.  *    Copyright © 1995 AmiTCP/IP Group,
  8.  *                     Network Solutions Development Inc.
  9.  *                     All rights reserved.
  10.  * 
  11.  *      
  12.  */
  13.  
  14. /*
  15.  * Get the phone number and retry count
  16.  */
  17. OPTIONS results
  18. ARG maxRetries
  19.  
  20. Get PhoneNumber
  21.  
  22. /* 3 retries by default */
  23. if (maxRetries = "") then maxRetries = 3
  24.  
  25. Get ModemDialPrefix
  26.  
  27. if ( PhoneNumber = "" | ModemDialPrefix = "" ) then do 
  28.   Status "No phone number or dial prefix, cannot dial!"
  29.   pause 5
  30.   exit 10
  31. end
  32.  
  33. Status "Dialing number" PhoneNumber||"..."
  34.  
  35. /*
  36.  * Set Inter-character delay to 100 ms.
  37.  * Some modems need this.
  38.  */
  39. Set InterCharDelay 100
  40. OldDelay = result /* save the old value */
  41.  
  42. /*
  43.  * Set the WaitFor timeout to 60 seconds.
  44.  * Modem needs to respond in this time.
  45.  */
  46. Set WaitForTimeout 60
  47. OldTimeOut = result  /* save the old value */
  48.  
  49. /* enable error signal */
  50. signal on error
  51.  
  52. /* Initialize variables */
  53. dialPrefix = ModemDialPrefix
  54. onOnlineState = 0  /* assume not in online state */
  55. retries = 0
  56.  
  57. do until (onOnlineState)
  58.   /*
  59.    * Send the dial command
  60.    */
  61.   SendLn dialPrefix||phonenumber
  62.  
  63.   /*
  64.    * Wait for our command to be echoed back
  65.    */
  66.   WaitFor phonenumber||"\r"
  67.  
  68.   /*
  69.    * Wait for dial result. CONNECT is the succesfull case.
  70.    */
  71.   WaitFor "CONNECT|NO CARRIER|BUSY|ERROR|NO DIALTONE|NO ANSWER|OK"
  72.  
  73.   if (result = 1) then do
  74.     Status "Dialing Succeeded."
  75.     onOnlineState = 1
  76.     ModemOnline YES  /* now use Carrier Detect if configured */
  77.   end
  78.   else do
  79.     if (retries > maxRetries) then do
  80.       Status "Could not dial to the number" phonenumber
  81.       exit 10
  82.     end
  83.     Status "Redialing number" phonenumber||"..."
  84.     retries = retries + 1
  85.   end
  86. end
  87.  
  88. /*
  89.  * return old values
  90.  */
  91. Set WaitForTimeout OldTimeOut
  92. Set InterCharDelay OldDelay
  93. exit 0
  94.  
  95. error:
  96. Say "Dial.ssrx: Command on line" SIGL "returned" RC ":" SerScript.LASTERROR
  97. Exit 10
  98.